package com.kzj.laimeimei.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;

import com.kzj.laimeimei.R;


public class CameraDialog extends Dialog {

	public CameraDialog(Context context, int theme) {
		super(context, theme);
	}

	public static CameraDialog create(Context context,final CameraDialogAction action) {
		final CameraDialog dialog = new CameraDialog(context, R.style.style_share_dialog);
		dialog.getWindow().setWindowAnimations(R.style.dialogWindowAnim);
		LayoutInflater inflater = LayoutInflater.from(context);
		View contentView = inflater.inflate(R.layout.template_photo_select_dialog, null);
		
		Button btn_ablum = (Button) contentView.findViewById(R.id.btn_album);
		Button btn_camera = (Button) contentView.findViewById(R.id.btn_camera);
		Button btn_cancel = (Button) contentView.findViewById(R.id.btn_cancel);

		
		dialog.setContentView(contentView);
		dialog.setCanceledOnTouchOutside(false);
		contentView.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				
				if(dialog.isShowing()){
					dialog.dismiss();
				}
				return false;
			}
		});
		
		btn_ablum.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				action.clickAblum();
				dialog.dismiss();
			}
		});
		btn_camera.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				action.clickCamera();
				dialog.dismiss();
			}
		});
		btn_cancel.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
				
			}
		});
		return dialog;
	}

}
